<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script>
    $(function(){
        var startDate =$('#startDate').val();
        var date = currentTime();
        if(startDate<date){
            $('#date').val(date);
        }
    });
    function changePrice(inputId,inputId2){
        var inputValue = $.trim($("#"+inputId).val());
        if(inputValue!=null&&inputValue!=''){
            $("#"+inputId2).val(inputValue);
        }

    }
    function currentTime() {
        var now = new Date();
        var year = now.getFullYear();
        var month = now.getMonth() + 1;
        var day = now.getDate();
        var hh = now.getHours();
        var mm = now.getMinutes();
        var ss = now.getSeconds();
        var clock = year + "-";
        if (month < 10)
            clock += "0";
        clock += month + "-";
        if (day < 10)
            clock += "0";
        clock += day + " ";
        if (hh < 10)
            clock += "0";
        clock += hh + ":";
        if (mm < 10)
            clock += '0';
            clock += mm + ":";
        if (ss < 10)
            clock += '0';
        clock += ss;
        return (clock);

    }
</script>
<div class="content-wrap">
        <div class="wrapper" style="bottom: 50px;">
            <ul class="nav nav-tabs">
                <li>
                    <a href="#"  onclick="loadDiv('mainCenterDiv','${ctx}/oper/priceList/index')">价表列表</a>
                </li>
                <li class="active">
                    <a href="#">
                        价表调价
                    </a>
                </li>
            </ul>
            <section class="panel panel-default">
                <div class="panel-body">
                    <div class="row">
                            <div class="col-lg-6">
                                <header class="panel-heading">原价</header>
                                <div class="panel-body">
                                    <form:form  modelAttribute="currentPriceList" class="form-horizontal">
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">项目名称：</label>
                                            <div class="col-sm-4">
                                                <input name="citemName"readonly class="form-control"  maxlength="200" value="${currentPriceList.itemName}"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">价格：</label>
                                            <div class="col-sm-4">
                                                <input name="cprice"  class="form-control"  readonly  value="${currentPriceList.price}"/>
                                            </div>
                                        </div>
                                        <div class="form-group display-none">
                                            <label class="col-sm-2 control-label">优惠价格：</label>
                                            <div class="col-sm-4">
                                                <input name="cpreferPrice" readonly  class="form-control"  value="${currentPriceList.preferPrice}"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">开始时间：</label>
                                            <div class="col-sm-4">
                                                <input name="cstartDate"  class="form-control"  readonly  value='<fmt:formatDate value="${currentPriceList.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>'/>
                                            </div>
                                        </div>
                                    </form:form>
                                </div>
                            </div>
                            <div class="col-lg-6">
                                <header class="panel-heading">调价</header>
                                <div class="panel-body">
                                    <form:form id="inputForm" data-parsley-validate="" modelAttribute="priceList" onsubmit="return formSaveLoad('mainCenterDiv','inputForm','${ctx}/oper/priceList/updatePriceSave','${ctx}/oper/priceList/index');" method="post" class="form-horizontal">
                                    <form:hidden path="id"/>
                                    <form:hidden path="orgId"/>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">项目名称：</label>
                                            <div class="col-sm-4">
                                                <form:input path="itemName" htmlEscape="false" readonly="true" class="form-control"  maxlength="200" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">价格：</label>
                                            <div class="col-sm-4">
                                                <form:input path="price" id="price" htmlEscape="false" class="form-control"  data-parsley-required="true" data-parsley-twonum="1" onblur="return changePrice('price','preferPrice');"/>
                                            </div>
                                        </div>
                                        <div class="form-group display-none">
                                            <label class="col-sm-2 control-label">优惠价格：</label>
                                            <div class="col-sm-4">
                                                <form:input path="preferPrice" id="preferPrice" htmlEscape="false" class="form-control" data-parsley-required="true" data-parsley-twonum="1"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-2 control-label">开始时间：</label>
                                            <div class="col-sm-4">
                                                <input id="startDate" value="<fmt:formatDate value="${currentPriceList.startDate}" pattern="yyyy-MM-dd HH:mm:ss"></fmt:formatDate>" type="hidden"/>
                                                <input name="startDate" id="date" htmlEscape="false" class="form-control" data-parsley-required="true" readonly
                                                       onfocus="var startDate =$('#startDate').val();if(startDate<currentTime()){WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:currentTime()})}else{WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:startDate})}" value='<fmt:formatDate value="${currentPriceList.startDate}" pattern="yyyy-MM-dd HH:mm:ss"/>'/>

                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <div class="col-sm-offset-2 col-sm-10">
                                                <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存">&nbsp;
                                                <input id="btnCancel" class="btn" type="button" value="返 回" onclick="loadDiv('mainCenterDiv','${ctx}/oper/priceList/index')">
                                            </div>
                                        </div>
                                    </form:form>
                                </div>
                            </div>

                            </div>
                    </div>
            </section>
        </div>
    </div>